﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Hxsoft.AppV1.Module;

namespace Hxsoft.AppV1.Admin.ArticleManage.Controls
{
	public partial class Article : BaseUserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
				this.DataBind();
		}

		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);

			FCKeditor.BindUploadUrl(CtrlArtContent, GlobalID, Articles.INFO_TYPE, SiteId);
			FCKeditor.BindUploadUrl(CtrlLink, GlobalID, Articles.INFO_TYPE, SiteId);
		}
		/// <summary>
		/// 属性 Title
		/// </summary>
		public string Title
		{
			get
			{
				return Convert.ToString(CtrlTitle.Text);
			}
			set
			{
				CtrlTitle.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 MiddleTitle
		/// </summary>
		public string MiddleTitle
		{
			get
			{
				return Convert.ToString(CtrlMiddleTitle.Text);
			}
			set
			{
				CtrlMiddleTitle.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ShortTitle
		/// </summary>
		public string ShortTitle
		{
			get
			{
				return Convert.ToString(CtrlShortTitle.Text);
			}
			set
			{
				CtrlShortTitle.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ViceTitle
		/// </summary>
		public string ViceTitle
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlViceTitle.Text))
					return null;

				return Convert.ToString(CtrlViceTitle.Text);
			}
			set
			{
				if (value == null)
					CtrlViceTitle.Text = "";
				else
					CtrlViceTitle.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ArticleCode
		/// </summary>
		public string ArticleCode
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlArticleCode.Text))
					return null;

				return Convert.ToString(CtrlArticleCode.Text);
			}
			set
			{
				if (value == null)
					CtrlArticleCode.Text = "";
				else
					CtrlArticleCode.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ImageType
		/// </summary>
		public string ImageType
		{
			get
			{
				return Convert.ToString(ImageUploader.Value);
			}
			set
			{
				ImageUploader.Value = value;
			}
		}

		/// <summary>
		/// 属性 Keywords
		/// </summary>
		public string Keywords
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlKeywords.Text))
					return null;

				return Convert.ToString(CtrlKeywords.Text);
			}
			set
			{
				if (value == null)
					CtrlKeywords.Text = "";
				else
					CtrlKeywords.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ArtSource
		/// </summary>
		public string ArtSource
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlArtSource.Text))
					return null;

				return Convert.ToString(CtrlArtSource.Text);
			}
			set
			{
				if (value == null)
					CtrlArtSource.Text = "";
				else
					CtrlArtSource.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 Summary
		/// </summary>
		public string Summary
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlSummary.Text))
					return null;

				return Convert.ToString(CtrlSummary.Text);
			}
			set
			{
				if (value == null)
					CtrlSummary.Text = "";
				else
					CtrlSummary.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ArtContent
		/// </summary>
		public string ArtContent
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlArtContent.Value))
					return null;

				return Convert.ToString(CtrlArtContent.Value);
			}
			set
			{
				if (value == null)
					CtrlArtContent.Value = "";
				else
					CtrlArtContent.Value = value.ToString();
			}
		}

		/// <summary>
		/// 属性 MobileContent
		/// </summary>
		public string MobileContent
		{
			get
			{
				return CtrlMobileContent.Value;
			}
			set
			{
				CtrlMobileContent.Value = value;
			}
		}

		/// <summary>
		/// 属性 Link
		/// </summary>
		public string Link
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlLink.Value))
					return null;

				return Convert.ToString(CtrlLink.Value);
			}
			set
			{
				if (value == null)
					CtrlLink.Value = "";
				else
					CtrlLink.Value = value.ToString();
			}
		}

		/// <summary>
		/// 属性 ReleaseDate
		/// </summary>
		public DateTime ReleaseDate
		{
			get
			{
				return Convert.ToDateTime(CtrlReleaseDate.Text);
			}
			set
			{
				CtrlReleaseDate.Text = value.ToString();
			}
		}
		/// <summary>
		/// 控件的 ArticleInfo 实例。
		/// </summary>
		public Module.Article Info
		{
			get
			{
				Module.Article article = new Module.Article();

				article.GlobalId = GlobalID;
				article.Title = Title;
				article.MiddleTitle = MiddleTitle;
				article.ShortTitle = ShortTitle;
				article.ViceTitle = ViceTitle;
				article.ArticleCode = ArticleCode;
				article.ImageType = ImageType;
				article.Keywords = Keywords;
				article.ArtSource = ArtSource;
				article.Summary = Summary;
				article.ArtContent = ArtContent;
				article.MobileContent = MobileContent;
				article.Link = Link;
				article.ReleaseDate = ReleaseDate;			

				return article;
			}
			set
			{
				if (value == null) return;

				GlobalID = value.GlobalId;
				Title = value.Title;
				MiddleTitle = value.MiddleTitle;
				ShortTitle = value.ShortTitle;
				ViceTitle = value.ViceTitle;
				ArticleCode = value.ArticleCode;
				ImageType = value.ImageType;
				Keywords = value.Keywords;
				ArtSource = value.ArtSource;
				Summary = value.Summary;
				ArtContent = value.ArtContent;
				MobileContent = value.MobileContent;
				Link = value.Link;
				ReleaseDate = value.ReleaseDate;
			}
		}
	}
}